﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Intelsi.BusinessLogic;
using Intelsi.Entity;
using Microsoft.Practices.Unity;

namespace Intelsi.WB
{
    public partial class frmListarProveedor : System.Web.UI.Page
    {
        [Dependency]
        public IProveedorBL proveedorBL { get; set; }

        [Dependency]
        public ITrabajadorBL trabajadorBL { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            string userName = HttpContext.Current.User.Identity.Name;
            var trabajador = trabajadorBL.GetFromTrabajadorByCorreoCorporativo(userName);

            string cargo = trabajador.Cargo;

            if (cargo == "Almacenero" || cargo == "Gerente")
            {

            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(),
                               "mensaje",
                                  "<script type=\"text/javascript\">" +
                                     "alert(\"Usted No tiene Los Permiso Nesesarios Para esto\");" +
                                     "document.location=('Default.aspx');" +
                                       "</script>", false);


            }
        }

        protected void ObjectDataSource1_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            e.ObjectInstance = proveedorBL;
        }

        protected void btnNuevo_Click(object sender, EventArgs e)
        {
            Response.Redirect("FrmProveedor.aspx?acc=nuevo");
        }
    }
}